<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<script>
  /*//定义
  var str = new String("hello");
  var str1 = "world";
  alert(str); //hello
  alert(str1);  //world
  alert(str + str1 + "!") //helloworld!*/

  /*//属性
  var str2 = "乾坤未定";
  alert(str2.length); //4*/

 /* //方法
  var str3 = "itcast";
  var s = str3.charAt(0);
  var index1 = str3.indexOf("c");
  var index2 = str3.indexOf("1");
  alert(s); //i
  alert(index1);  //2
  alert(index2);  //-1*/

  //trim()
  var username = "  zhangsan   ";
  var str1 = 1 + username + 1;
  var str2 = 1 + username.trim() + 1;
  alert(str1);  //1  zhangsan   1
  alert(str2);  //1zhangsan1
</script>
</body>
</html>